package com.dcw.lixb.designmode.filter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lixiaobin
 * @date 2020-07-21 15:07:38
 * @desc 描述信息
 */
public class AndCriteria implements Criteria {

    private final Criteria[] mCriterias;

    public AndCriteria(Criteria... criteria) {
        mCriterias = criteria;
    }

    @Override
    public List<Person> meetCriteria(List<Person> persons) {
        List<Person> ret = new ArrayList<>();
        ret.addAll(persons);
        if (null != mCriterias) {
            for (Criteria ct : mCriterias) {
                ret =  ct.meetCriteria(ret);
            }
        }
        return ret;
    }
}
